﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Global;

public partial class Table_Default : System.Web.UI.Page
{
    string m_strPos;
    int m_iFlag = -1;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             
            if((int)Session["flag" ]== 1)
            {
          
                TBAverageCost.Text = Session["consume"].ToString();
                TBSeatNum.Text = Session["tablenum"].ToString();
                
               
                  
            }
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Table tb = new Table();
        tb.SetAverageCost(int.Parse(TBAverageCost.Text.ToString()));
        tb.SetSeatNum(int.Parse(TBSeatNum.Text.ToString()));

       tb.SetAttributeID(int.Parse( ListAttribute.SelectedValue.ToString()));

        int iResID = int.Parse(Session["resid"].ToString());
        tb.SetResID(iResID);
        tb.SetID(int.Parse(Session["id"].ToString()));
         

        

       // TableManager TabManager = new TableManager();

        CreateManager Creator = new CreateManager();
        BaseManager TabManager = Creator.GetManager(2);

        

        bool b = false ;
        if ((int)Session["flag"] == 1)
        {
              //  b = TabManager.UpdateTable(tb);
            b = TabManager.UpdateObject(tb);
           

        }
        else
        {
           // b = TabManager.AddTable(tb);
            b = TabManager.AddObject(tb);

        }
        
        if (b)
        {
            Response.Redirect("ManageTable.aspx" );
        }

       
        
        
    }
    protected void ListAttribute_SelectedIndexChanged(object sender, EventArgs e)
    {
        m_iFlag = 0;

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect(@"~/seat/managetable.aspx");
    }
}
